<extend name="public:template"/>

<block name="title">内容编辑</block>
<block name="style">
	<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/webuploader.css">
	<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/diyUpload.css">
</block>
<block name="content">
	<div class="wrap-page">
		<div id="pageMemberInfo" class="page-content">
			<form class="form default-style" role="form" action="{:u('backend/article/add')}" method="post">

				<input type="hidden" id="json_cate_list" value='{$cate_list}'>
				<input type="hidden" name="id" value='{$article.id}'>

				<div id="tabSwitchProduct" class="tab-switch">

					<!--选项卡-->
					<div class="tabs-title clearfix">
						<ul>
							<li class="current"><a data-id="tab-basic" href="javascript:;">基本信息</a></li>
							<li><a data-id="tab-seo" href="javascript:;">{:L('article_seo')}</a></li>
						</ul>
					</div>
					<!--选项卡-->

					<!--编辑区域-->
					<div class="tab-content">
						<div id="tab-basic-content" class="tab-content-inner">
							<div id="boxBasicInfo" class="box">
								<div class="box-content">

									<dl class="clearfix">
										<dt><label>{:L('article_cateid')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<select class="J_cate_select mr10" data-pid="0" data-uri="{:U('backend/article_cate/ajax_getchilds')}" data-selected="{$article.cate_path}">

												</select>
												<input type="hidden" name="cate_id" id="cate_id" value="{$article.cate_id}" /></td>

											</div>
										</dd>
									</dl>
									<dl class="clearfix">
										<dt><label>{:L('article_title')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<input id="title" placeholder="请输入文章标题" class="textfield" type="text" value="{$article.title}" name="title" />
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>{:L('article_img')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<div id="box">
													<div id="container" >
													</div>
													<div id="test"></div>
												</div>
												<input type="hidden" name="img" id="img" class="input-text" value="{$article.thumb}" /></td>

											</div>
										</dd>
									</dl>
									<dl class="clearfix">
										<dt><label>{:L('author')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<input id="source" placeholder="请输入来源" class="textfield" type="text" value="{$article.source}" name="source" />
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>{:L('article_desc')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<textarea name="intro" id="abst" class="textarea">{$article.intro}</textarea>
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>详细内容：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<textarea name="content" id="content">{$article.content}</textarea>
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>发布状态：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<div class="radio-layout-h clearfix">
													<div class="radio-item">
														<span class="radio-field"><input class="radio" value="1" name="status" type="radio" <eq name="article.status" value="1">checked="checked"</eq> /></span>
														<span class="radio-text"><label >是</label></span>
													</div>
													<div class="radio-item">
														<span class="radio-field"><input class="radio"  value="0" name="status" type="radio" <eq name="article.status" value="0">checked="checked"</eq> /></span>
														<span class="radio-text"><label >否</label></span>
													</div>
												</div>
											</div>
										</dd>
									</dl>

								</div>
							</div>
						</div>

						<div id="tab-seo-content" class="tab-content-inner" style="display: none">
							<div class="box">
								<div class="box-content">
									<dl class="clearfix">
										<dt><label>{:L('seo_title')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<input id="seo_title" placeholder="请输入{:L('seo_title')}"  class="textfield" type="text" name="seo_title" value="{$article.seo_title}" />
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>{:L('seo_keys')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<input id="seo_keys" placeholder="请输入{:L('seo_keys')}"  class="textfield" type="text" name="seo_keywords" value="{$article.seo_keywords}" />
											</div>
										</dd>
									</dl>

									<dl class="clearfix">
										<dt><label>{:L('seo_desc')}：</label></dt>
										<dd>
											<div class="item-field clearfix">
												<textarea id="seo_description" placeholder="请输入{:L('seo_desc')}"  class="textarea" type="text" name="seo_description">{$article.seo_description}</textarea>
											</div>
										</dd>
									</dl>

								</div>
							</div>
						</div>
					</div>
					<!--编辑区域END-->
				</div>
				<div class="page-buttons clearfix">
					<div class="fl-l">
						<button type="button" class="button button-blue" id="dosubmit">保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</block>
<block name="script">
	<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/webuploader.html5only.min.js"></script>
	<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/diyUpload.js"></script>
	<script charset="utf-8" src="__STATIC__/editor/kindeditor-all-min.js"></script>
	<script charset="utf-8" src="__STATIC__/editor/lang/zh-CN.js"></script>
	<script>
	$(function() {
	//初始化编辑器
	KindEditor.ready(function(K) {
	window.editor = K.create('#content',{
	width: '730px',
	height: '360px',
	afterBlur: function(){this.sync();}
	});
	});

	cate_select_init();
	$('#dosubmit').click(function(){
	var cate_id = $('#cate_id').val();
	var title   = $('#title').val();
	var content = editor.html();
	if(!$.trim(cate_id))
	{
	layer.msg('请选择分类');
	return false;
	}
	if(!$.trim(title))
	{
	layer.msg('请输入文章标题');
	return false;
	}
	if(!$.trim(content))
	{
	layer.msg('请输入文章内容');
	return false;
	}
	$('#info_form').submit();
	});

	$('#test').diyUpload({
	fileNumLimit:1,
	container: 'container', //图片预览容器
	url:"{:U('backend/upload/index', array('cate' => 'article'))}",
	success:function( data ) {
	//console.info(data.data.file.name);
	var img_path = '/article/'+ data.data.file.savepath + data.data.file.savename
	$('#img').val(img_path)
	},
	error:function( err ) {
	//console.info( err );
	}

	});
	$('.diyCancel').click(function(){
	$(this).parents('li').remove();
	$('#img').val('')
	})

	});
	</script>
</block>